
setTimeout(function(){
	$("#dictionary_editDicName").focus();
	$("#dictionary_editDicName").rules("add",{
		remote: {
			url : 'sys/dic/checkEditName?name='+$("#dictionary_editDicName").val()+"&id="+getQueryString("id"),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			}
		}, 
		messages: {remote: "该字典名称已存在"}
		
	}); 
} , parseInt(Math.random() * 1000)); 


setTimeout(function(){
	//$("#dictionary_editDicCode").focus();
	$("#dictionary_editDicCode").rules("add",{
		remote: {
			url : 'sys/dic/checkEditDicCode?code='+$("#dictionary_editDicCode").val()+"&id="+getQueryString("id"),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			}
		}, 
		messages: {remote: "该字典编码已存在"}
		
	}); 
} , parseInt(Math.random() * 1000)); 




var app = angular.module('dictionaryApp', []);

app.controller('dictionaryController', function($scope, $http, $location) {
	$scope.dictionary={};
	$scope.dictionary.pid=getQueryString("id");
	$scope.pwd;
	$scope.view=function(){
		$http.get(timestamp("sys/dic/get/"+getQueryString("id"))).success(function (response) {
			$scope.dictionary = response.data;
		});
	}
	
	$scope.view();
	$scope.refreshData=function(){
		$scope.view();
	}
	
	$scope.dicSave=function(){
	   if($("#myForm").valid()){
		   $http.put('sys/dic/update/', $scope.dictionary).success(function(){
               redirectUrl("manage/dictionary/","dicList.jsp?id="+$scope.dictionary.pid);
           });
	   }
	}
	
	$scope.dicReset=function(){
		$scope.view();
	}
	
	$scope.dicCancle=function(){
		//document.location.href='manage/dictionary/dicList.jsp?id='+$scope.dictionary.pid;
		redirectUrl("manage/dictionary/","dicList.jsp?id="+$scope.dictionary.pid);
	}
});